<?php
// 连接数据库
require '../script/mysqlconfig.php';

$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$keyword = $_POST["search_term"];
$result = mysqli_query($conn,"SELECT * FROM hosts where serial_number LIKE '%".$keyword."%' or bmc_ip = '$keyword' or manage_ip= '$keyword' or yewu_ip= '$keyword'");

echo "<table border='1' style='border-collapse: collapse;'>";
//echo "<tr><th>ID</th><th>设备品牌</th><th>型号</th><th>序列号</th></tr>";
echo "<tr><th>ID</th><th>设备品牌</th><th>型号</th><th>序列号</th><th>设备类型</th><th>所在机房</th><th>机柜</th><th>开始U位</th><th>结束U位</th><th>设备使用状态</th><th>设备的用途</th><th>带外IP地址</th><th>管理IP地址</th><th>业务IP地址</th><th>设备归属</th><th>资产归属部门</th><th>资产归属人员</th><th>公司资产编码</th><th>设备使用部门</th><th>设备使用人</th><th>客户号</th><th>客户名字</th><th>备注</th><th>功能区</th></tr>";
while($row = mysqli_fetch_assoc($result)){
    echo "<tr>";
    echo "<td>".$row['id']."</td>";
    echo "<td>".$row['brand']."</td>";
    echo "<td>".$row['model']."</td>";
    echo "<td>".$row['serial_number']."</td>";
    echo "<td>".$row["device_type"]."</td>";
    echo "<td>".$row["room"]."</td>";
    echo "<td>".$row["cabinet"]."</td>";
    echo "<td>".$row["start_u"]."</td>";
    echo "<td>".$row["end_u"]."</td>";
    echo "<td>".$row["device_status"]."</td>";
    echo "<td>".$row["device_feature"]."</td>";
    echo "<td>".$row["bmc_ip"]."</td>";
    echo "<td>".$row["manage_ip"]."</td>";
    echo "<td>".$row["yewu_ip"]."</td>";
    echo "<td>".$row["device_belong"]."</td>";
    echo "<td>".$row["belong_en"]."</td>";
    echo "<td>".$row["belong_op"]."</td>";
    echo "<td>".$row["asset_code"]."</td>";
    echo "<td>".$row["use_en"]."</td>";
    echo "<td>".$row["use_operator"]."</td>";
    echo "<td>".$row["client_no"]."</td>";
    echo "<td>".$row["client_name"]."</td>";
    echo "<td>".$row["other"]."</td>";
//    echo "<td><a href='edit.php?id=".$row['id'] . "' style='text-decoration:none;color:black;'>编辑</a></td>";
    echo "<td><a href='selecthost3edit.php?id=".$row['id'] . "'>编辑</a> <a href='selecthost4del.php?id=".$row['id'] . "'>删除</a></td>";
    echo "</tr>";
}
echo "</table>";

mysqli_close($conn);
